package com.westa.smallshop.login;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import com.westa.smallshop.R;
import com.westa.smallshop.common.BaseActivity;
import com.westa.smallshop.data.source.remote.AccountRemoteDataSource;
import com.westa.smallshop.util.ActivityUtils;

/**
 * Created by cy123 on 2016/9/13.
 */
public class LoginActivity extends BaseActivity {

    public static void startActivity(Activity activity) {

        Intent intent = new Intent(activity, LoginActivity.class);
        activity.startActivity(intent);

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);

        setHasNavigationIcon(false);
        LoginFragment loginFragment = (LoginFragment) getSupportFragmentManager()
                .findFragmentById(R.id.fragment_layout);

        if (loginFragment == null) {
            loginFragment = LoginFragment.newInstance();
            ActivityUtils.addFragmentToActivity(getSupportFragmentManager(),
                    loginFragment, R.id.fragment_layout);

        }

        new LoginPresenter(loginFragment, new AccountRemoteDataSource(getApplicationContext()));
    }
}
